package com.hhhn.wk.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hhhn.wk.R;


/**
 * * * * * * * * * * * *
 * @author：WenKe ｡◕‿◕｡ *
 * Data：2017     ｡◕‿◕｡ *
 * QQ：370820580  ｡◕‿◕｡ *
 * Function：     ｡◕‿◕｡ *
 *
 * * * * * * * * * * * */
public class ClassifyMessageFenXiang {
    public interface OnClassifyMessageFenXiang {
        void onClick(int whichButton);
    }
    private ClassifyMessageFenXiang() {
    }
    public static Dialog showSheet(final Context context, final OnClassifyMessageFenXiang actionSheetSelected, DialogInterface.OnCancelListener cancelListener) {
        final Dialog dlg = new Dialog(context, R.style.ActionSheet);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.classify_message_fenxiang, null);
        final int cFullFillWidth = 10000;
        layout.setMinimumWidth(cFullFillWidth);
        LinearLayout ll_wx = (LinearLayout) layout.findViewById(R.id.ll_wx);
        LinearLayout ll_wxq = (LinearLayout) layout.findViewById(R.id.ll_wxq);


        //微信
        ll_wx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                actionSheetSelected.onClick(1);
                dlg.dismiss();
            }
        });
        //微信朋友圈
        ll_wxq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                actionSheetSelected.onClick(2);
                dlg.dismiss();
            }
        });

        Window w = dlg.getWindow();
        WindowManager.LayoutParams lp = w.getAttributes();
        lp.x = 0;
        final int cMakeBottom = -1000;
        lp.y = cMakeBottom;
        lp.gravity = Gravity.BOTTOM;
        dlg.onWindowAttributesChanged(lp);
        dlg.setCanceledOnTouchOutside(true);
        if (cancelListener != null)
            dlg.setOnCancelListener(cancelListener);
        dlg.setContentView(layout);
        dlg.show();
        return dlg;
    }
}
